class HttpException extends Error {
  constructor(msg='服务器异常', errorCode=1000, code=400) {
    super()
    this.errorCode = errorCode
    this.code = code
    this.msg = msg
  }
}

class ParameterException extends HttpException {
  constructor(msg, errorCode) {
    super()
    this.msg = msg || '参数异常'
    this.errorCode = errorCode || 10000
    this.code = 400
  }
}

/* 
  操作成功的异常类
*/
class Success extends HttpException {
  constructor(msg, errorCode) {
    super()
    this.msg = msg || 'ok'
    this.errorCode = errorCode || 0
    this.code = 200
  }
}

//  未找到数据

class NotFound extends HttpException {
  constructor(msg, errorCode) {
    super()
    this.msg = msg || 'NotFound !'
    this.errorCode = errorCode || 1000
    this.code = 404
  }
}

// 授权失败，密码不正确

class AuthFailed extends HttpException {
  constructor(msg, errorCode) {
    super()
    this.msg = msg || '授权失败'
    this.errorCode = errorCode || 1004
    this.code = 401
  }
}

// 禁止访问

class Forbbiden extends HttpException {
  constructor(msg, errorCode) {
    super()
    this.msg = msg || '禁止访问'
    this.errorCode = errorCode || 1006
    this.code = 403
  }
}

module.exports = {
  HttpException,
  ParameterException,
  Success,
  NotFound,
  AuthFailed,
  Forbbiden
}